<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:py="http://genshi.edgewall.org/">
  <xi:include href="discussion-macros.html"/>
  <xi:include href="admin.html"/>
  <head>
    <title>Discussion Forums</title>
  </head>

  <py:with vars="is_edit = discussion.group.id and not req.args.submit">
    <body>
      <h2>Forum Groups</h2>

      <form id="${is_edit and 'edit-group-form' or 'add-group-form'}" class="addnew" method="post" action="${panel_href()}">
        <div class="shaded-box">
        <fieldset id="rightpanel">
          <legend>
            ${is_edit and 'Edit Forum Group:' or 'Add Forum Group:'}
          </legend>
          <div class="inputrow">
            <div class="headtextfield">Name:</div>
            <div class="inputfield">
              <input type="text" id="name" name="name" value="${is_edit and discussion.group.name or None}"/>
            </div>
          </div>
          <div class="inputrow">
            <div class="headtextfield">Description:</div>
            <div class="inputfield">
              <input type="text" id="description" name="description" value="${is_edit and discussion.group.description or None}"/>
            </div>
          </div>
          <div class="buttons">
            <input type="submit" name="submit" value="${is_edit and 'Edit' or 'Add'}"/>
            <input py:if="is_edit" type="button" name="cancel" value="Cancel" onclick="location.href = '${panel_href()}'"/>
            <input py:if="is_edit" type="hidden" name="group" value="${discussion.group.id}"/>
            <input type="hidden" name="discussion_action" value="${is_edit and 'post-edit' or 'post-add'}"/>
          </div>
        </fieldset>
        </div>
      </form>

      <py:choose>
        <form py:when="len(discussion.groups) > 1" method="post" action="${panel_href()}">
          <table id="group-list" class="listing">
            <thead>
              <tr>
                <th class="sel">&nbsp;</th>
                ${sortable_th(discussion.order, discussion.desc, 'id', 'ID', panel_href())}
                ${sortable_th(discussion.order, discussion.desc, 'name', 'Name', panel_href())}
                ${sortable_th(discussion.order, discussion.desc, 'description', 'Description', panel_href())}
              </tr>
            </thead>
            <tbody>
              <py:for each="line, group in enumerate(discussion.groups)">
                <tr py:if="group.id" class="${line % 2 and 'even' or 'odd'}">
                  <td class="sel">
                    <input type="checkbox" name="selection" value="${group.id}"/>
                  </td>
                  <td class="id">
                    <div class="id">
                      <a href="${panel_href(group.id)}">
                        <span>${group.id}</span>
                      </a>
                    </div>
                  </td>
                  <td class="name">
                    <div class="name">
                      <a href="${panel_href(group.id)}">
                        <span>${group.name or '&nbsp;'}</span>
                      </a>
                    </div>
                  </td>
                  <td class="description">
                    <div class="description">
                      <a href="${panel_href(group.id)}">
                        <span>${group.description or '&nbsp;'}</span>
                      </a>
                    </div>
                  </td>
                </tr>
              </py:for>
            </tbody>
          </table>
          <br/>
          <div class="buttons">
			<input type="submit" name="remove" value="Remove selected items" onclick="return confirm('Do you really want to remove selected items?')"/>
            <input type="hidden" name="discussion_action" value="delete"/>
          </div>
        </form>
        <div py:otherwise="">
          <p class="help">As long as you don't add any items to the list, this field
            will remain completely hidden from the user interface.</p>
          <br style="clear: right"/>
        </div>
      </py:choose>
    </body>
  </py:with>
</html>